<?php
//    session_start();
//?>
<!--<!doctype html>-->
<!--<html lang="en">-->
<!--<head>-->
<!--    <meta charset="UTF-8">-->
<!--    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">-->
<!--    <meta http-equiv="X-UA-Compatible" content="ie=edge">-->
<!--    <title>汽车投票系统</title>-->
<!--    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">-->
<!--    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>-->
<!--    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>-->
<!--    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>-->
<!--    <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>-->
<!--    <script src="layer/layer.js"></script>-->
<!--    <style>-->
<!--        .login{text-align:right;margin-bottom:20px;}-->
<!--        .img{position:relative}-->
<!--        .row img{width:100%;}-->
<!--        .img .row{position:absolute; bottom:0; left:15px; background-color:rgba(0,0,0,0.5); width:100%; color:white;}-->
<!--        p{margin:10px 0 !important;}-->
<!--    </style>-->
<!--</head>-->
<!--<body>-->
<!--    <div class="container">-->
<!--        <h1 class="text-center">汽车投票系统</h1>-->
<!--        <p class="login">-->
<!--            --><?php
//                if(isset($_SESSION['LoggedUsername']) && $_SESSION['LoggedUsername'] != ''){
//                    //已经登录了
//            ?>
<!--                    当前登录:--><?php //echo $_SESSION['username']; ?><!--<a href="javascript:open('logout.php', '用户登录')"> 注销</a> / <a href="javascript:open('signup.php', '用户注册')">注册</a>-->
<!--            --><?php
//                }
//                else{
//            ?>
<!--                <a href="javascript:open('login.php', '用户登录')">登录</a> / <a href="javascript:open('signup.php', '用户注册')">注册</a>-->
<!--            --><?php
//                }
//            ?>
<!--        </p>-->
<!--        <div class="row">-->
<!--            --><?php
//                include_once "connect.php";
//                $sql = "select * from carinfo order by id desc";
//                $result = mysqli_query($conn, $sql);
//                $i = 1;
//                while($info = mysqli_fetch_array($result)) {
//            ?>
<!--            <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">-->
<!--                <div class="img">-->
<!--                    <a href="vote.php?id=--><?php //echo $info['id'] ?><!--"><img src="img/--><?php //echo $info['carPic'];?><!--"></a>-->
<!--                    <div class="row">-->
<!--                        <div class="col-xs-12 col-sm-8 col-md-6">-->
<!--                            <p class="text-center">--><?php //echo $info['carName']?><!--</p>-->
<!--                        </div>-->
<!--                        <div class="col-xs-12 col-sm-8 col-md-6">-->
<!--                            <p class="text-center">票数：--><?php //echo $info['carNum']?><!--</p>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--                <p class="text-center">--><?php //echo $info['carDesc']?>
<!--                </p>-->
<!--            </div>-->
<!--            --><?php //} ?>
<!--        </div>-->
<!--    </div>-->
<!--    <script>-->
<!--        function open(url, title) {-->
<!--            layer.open({-->
<!--                type: 2,-->
<!--                title: title,-->
<!--                area: ['700px', '450px'],-->
<!--                fixed: false, // 不固定-->
<!--                maxmin: true,-->
<!--                content: url,-->
<!--            });-->
<!--        }-->
<!--        function closeLayer() {-->
<!--            layer.closeAll();-->
<!--        }-->
<!--    </script>-->
<!--</body>-->
<!--</html>-->
<?php session_start(); ?> <!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">     <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu"
          crossorigin="anonymous">
    <title>我最爱的汽车投票</title>
    <script src="https://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>     <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
            crossorigin="anonymous"></script>
    <script src="layer/layer.js"></script>
    <style>         .login {
            text-align: right;
            margin-bottom: 20px;
        }

        .img {
            position: relative
        }

        .row img {
            width: 100%;
        }

        .img .row {
            position: absolute;
            bottom: 0;
            left: 15px;
            background-color: rgba(0, 0, 0, 0.5);
            width: 100%;
            color: white;
        }

        p {
            margin: 10px 0 !important;
        }     </style>
</head>
<body>
<div class="container"><h1 class="text-center">我最爱的车辆投票</h1>
    <p class="login">         <?php if (isset($_SESSION['loggedUsername']) and $_SESSION['loggedUsername'] != '') {             //说明已经登录了             ?>             当前登录者：<?php echo $_SESSION['loggedUsername']; ?>
            <a href="logout.php">注销</a> <a href="javascript:open('signup.php','用户注册')">注册</a> <a href="javascript:open('modify.php','修改资料')">修改资料</a>         <?php } else { ?><a
                href="javascript:open('login.php','用户登录')">登录</a> <a href="javascript:open('signup.php','用户注册')">注册</a>         <?php } ?>     </p>
    <div class="row">         <?php include_once 'connect.php';
        $sql = "select * from carinfo order by id desc ";
        $result = mysqli_query($conn, $sql);
        $i = 1;
        while ($info = mysqli_fetch_array($result)) { ?>
            <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
                <div class="img">                 <?php if (isset($_SESSION['loggedUsername']) and $_SESSION['loggedUsername'] != '') {                 //说明已经登录了                 ?><a
                            href="vote.php?id=<?php echo $info['id']; ?>"><img src="img/<?php echo $info['carPic']; ?>"></a>                 <?php } else { ?>                     <img
                            src="img/<?php echo $info['carPic']; ?>">                 <?php } ?>
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-6"><p class="text-center"><?php echo $info['carName']; ?></p></div>
                        <div class="col-xs-12 col-sm-4 col-md-6"><p class="text-center">当前票数：<?php echo $info['carNum']; ?></p></div>
                    </div>
                </div>
                <p><?php echo $info['carDesc']; ?></p></div>         <?php if ($i % 2 == 0) {
                echo '<div class="clearfix visible-sm-block"></div>';
            }
            if ($i % 3 == 0) {
                echo '<div class="clearfix visible-md-block"></div>';
            }
            if ($i % 4 == 0) {
                echo '<div class="clearfix visible-lg-block"></div>';
            }
            $i++;
        } ?>     </div>
</div>
<script>
    function open(url, title) {
        layer.open({
            type: 2,
            title: title,
            area: ['700px', '450px'],
            fixed: false, //不固定
            maxmin: true, content: url
        });
    }

    function closeLayer() {
        layer.closeAll();
    } </script>
</body>
</html>